fix: fix tooltip component positioning and add it to storybook #1031
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The tooltip is broken in a way that for unknown reasons
classNames
is not overriding classes properly. Taking the following component:and using it as follows
renders the following HTML
and as you can see there is still the
top-24
being applied and thetop-0
is doing nothing.Logging the
top
property shows that it is indeed passed in correctly:However the rendering is completely off and not working as expected
Solution
I fixed the class composition and added some more properties to also allow it to be positioned from the bottom. I kept the current positioning syntax to not break existing tooltips throughout Komiser.
I also added a Storybook component since it was not super clear from the beginning on how to actually use the component. I hope that the Story makes this a bit more clear that you need to wrap the Tooltip inside a relative positioned container and that you need to have an
peer
element which works as a trigger for the tooltip to show!Changes Made
bottom
to allow all varieties of positioningHow to Test
Either check out the branch or check Storybook
Screenshots
Notes
None
Checklist
Reviewers
To be reviewed by code owners